
Topic Name
Introduction to C#
Environment Setup
C# Keywords
Contextual Keywords
C# Namespaces
What Is Class?
What is Object?
Data Types
Nullable Types
C# Variables
What are Access Modifiers?
What is Property?
What is Indexer?
Hello world Program
What is Type conversion?
What is if else condition?
What is Array?
What is Jagged Array?
What is ArrayList?
What is List?
What is string and StringBuilder?
What is for loop?
What is foreach loop?
What is switch?
What is Method?
What is method overloading?
What is Constructor?
What is constructor overloading?
What is Boxing and Unboxing?
What is delegate in C# and uses of delegates?
What is Inheritance?
What are Value types and Reference types?
What is Exception Handling?
What is struct?
What is Dictionary?
What is Hashtable?
What is interface?
What is Abstraction?
What is Polymorphism?
What is Enums?
What is Sealed Class?
What is Partial Class?
Extension Methods?
What is static?
What is Encapsulation?
Difference between Equality Operator (==) and Equals() Method in C# ?
What is IEnumerable?
What is Serializing?
What is LINQ?
Differences between IEnumerable and IQueryable?
What is Multithreading?
What is File Handling?
What is late binding and early binding?
What is Singleton Design Patterns?
Early binding can flag errors at compile time. With late binding there is a risk of run time exceptions. Early binding is much better for performance and should always be preferred over late binding. Use late binding only when working with an object’s that are not available at compile time. Now given bellow the example the code and explain the code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Reflection;
using testForClass1;
namespace testFor
{
public class Program
{
static void Main(string[] args)
{
//early binding
Student student = new Student();
string earlyName = student.GetFullName("Farhan", "Sakib");
Console.WriteLine("early binding : " + earlyName);
//late binding
Assembly excutingAssembly = Assembly.GetExecutingAssembly();
Type studentType = excutingAssembly.GetType("testFor.Student");
object studentInstance = Activator.CreateInstance(studentType);
MethodInfo getFullNameMethod = studentType.GetMethod("GetFullName");
string[] parameters = new string[2];
parameters[0] = "Farhan";
parameters[1] = "Sakib";
string lateName = (string)getFullNameMethod.Invoke(studentInstance, parameters);
Console.WriteLine("late binding : " + lateName);
Console.Read();
}
}
public class Student
{
public string GetFullName(string firstName, string lastName)
{
return firstName + " " + lastName;
}
}
}
Early binding is show in compile time error and late binding show error in run time exceptions.